package com.gsnd.gsnd22estore.service.impl;

import com.gsnd.gsnd22estore.domain.EsAddress;
import com.gsnd.gsnd22estore.mapper.EsAddressMapper;
import com.gsnd.gsnd22estore.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddressServiceImpl implements AddressService {
    @Autowired
    EsAddressMapper addressMapper;

    @Override
    public List<EsAddress> getAllAddressByUserId(Integer userId) {
         return addressMapper.selectByUserId(userId);
    }

    @Override
    public void createAddress(EsAddress address) {
        addressMapper.createAddress(address);

    }

    @Override
    public void removeAddressById(Integer id) {
          addressMapper.removeAddressById(id);
    }

    @Override
    public void editAddressInfo(EsAddress address) {
        addressMapper.editAddressInfo(address);
    }

    @Override
    public void setDefaultAddress(Integer addressId, Integer userId) {
        addressMapper.setDefaultAddress(addressId,userId);
    }

    @Override
    public void changeDefaultAddress(Integer addressId, Integer userId) {
        addressMapper.setDefaultAddress(addressId,userId);
    }


}
